package org.dromara.assets.runner;

import org.dromara.assets.config.BinanceConfig;
import org.dromara.assets.dto.BinanceAccount;
import org.dromara.assets.service.impl.BinanceWebSocket;
import lombok.extern.slf4j.Slf4j;
import org.dromara.assets.service.impl.BinanceWebSocketWithNew;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class BinanceRunner implements ApplicationRunner {

    private final BinanceConfig binanceConfig;
    private final ApplicationContext applicationContext;


    @Autowired
    public BinanceRunner(BinanceConfig binanceConfig, ApplicationContext applicationContext) {
        this.binanceConfig = binanceConfig;
        this.applicationContext = applicationContext;
    }

    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        log.info("初始化,accounts:{}", binanceConfig.getAccounts());
//        for (BinanceAccount account : binanceConfig.getAccounts()) {
//            String apiKey = account.getApiKey();
//            String apiSecret = account.getApiSecret();
//            BinanceWebSocket binanceWebSocket = applicationContext.getBean(BinanceWebSocket.class);
//            binanceWebSocket.init(apiKey, apiSecret);
//        }
        BinanceWebSocketWithNew binanceWebSocketWithNew = applicationContext.getBean(BinanceWebSocketWithNew.class);
        binanceWebSocketWithNew.start("DyJq9gihHFUIJwFCNnrKUyOPF1wmERrhUCZbnUgrxjzfQs78itpxVxvy95vPcNuq", "/etc/config/id_ed25519/id_ed25519", "X9!n#Dey9");

    }
}
